# 支持多重继承
# 语法：
# class 类名(父类列表):
#   pass
# 调用父类方法：
# 方法一：super(参数列表)
# 方法二：父类名称.方法名(self, 参数列表)
# 子类继承了父类除构造方法之外的所有成员，【包括私有成员(私有成员的前缀还是 `_父类名`)】


class Animal:
    def __init__(self, name, age):
        self.name = name
        self.age = age
        self.__gender = "m"

    def info(self):
        return "Name: {}, age: {}".format(self.name, self.age)

    @property
    def age(self):
        return self.__age

    @age.setter
    def age(self, age):
        if age < 0 or age > 1000:
            raise "年龄错误"
        self.__age = age

    def __str__(self):
        return self.info()


class Dog(Animal):
    def __init__(self, name, age, color):
        # -- 调用父类构造方法 --
        # Animal.__init__(self, name, age) # 方式1
        # super(Dog, self).__init__(name, age)  # 方式2
        super().__init__(name, age)  # 方式3
        self.color = color

    def info(self):
        # return "{}, color: {}".format(Animal.info(self), self.color)
        # return "{}, color: {}".format(super(Dog, self).info(), self.color)
        return "{}, color: {}".format(super().info(), self.color)

    @property
    def age(self):
        return Animal.age

    @age.setter
    def age(self, age):
        if age > 10:
            raise "你怕是养了一条啸天犬"
        Animal.age = age


print(Dog.mro())  # 继承层次

ami = Dog("阿咪", 3, "黄")
print(ami.info())
# print(dir(ami))
print(ami)  # __str__ 方法
